#ifndef RESPONSIVETEST_H
#define RESPONSIVETEST_H

#include <QObject>
#include <QTimer>
#include <QDebug>
#include "responsivefactory.h"
#include "sonyperformancemonitor.h"

/**
 * 🎨 ResponsiveTest - 响应式系统集成测试
 *
 * 验证Sony Ive响应式文件列表的完整功能
 */

class ResponsiveTest : public QObject
{
    Q_OBJECT

public:
    explicit ResponsiveTest(QObject* parent = nullptr);
    ~ResponsiveTest() = default;

    // === 测试执行 ===
    void runAllTests();
    void runComponentTests();
    void runPerformanceTests();
    void runIntegrationTests();

    // === 测试结果 ===
    bool allTestsPassed() const;
    QStringList getFailedTests() const;
    QString getTestSummary() const;

public slots:
    void onPerformanceWarning(const QString& warning);
    void onOptimizationSuggested(const QString& suggestion);

private slots:
    void onTestTimeout();

private:
    // === 具体测试方法 ===
    bool testResponsiveFactory();
    bool testResponsiveFileListEngine();
    bool testResponsiveFileItem();
    bool testAdaptiveFileLayout();
    bool testPerformanceMonitor();
    bool testSonyDesignIntegration();
    bool testConfigurationSystem();
    bool testMemoryManagement();
    bool testAnimationSystem();
    bool testCachePerformance();

    // === 测试辅助方法 ===
    void setupTestData();
    void cleanupTestData();
    void logTestResult(const QString& testName, bool passed, const QString& details = QString());
    void simulateUserInteractions();
    void measurePerformanceMetrics();

    // === 成员变量 ===
    ResponsiveFactory* m_factory;
    SonyPerformanceMonitor* m_performanceMonitor;
    QTimer* m_testTimer;

    // === 测试数据 ===
    QList<UnifiedFileInfo> m_testFiles;
    CustomFileListWidget* m_testWidget;
    ResponsiveFileListEngine* m_testEngine;

    // === 测试结果 ===
    QStringList m_passedTests;
    QStringList m_failedTests;
    int m_totalTests = 0;
    int m_passedCount = 0;
    int m_failedCount = 0;

    // === 测试配置 ===
    static constexpr int TEST_TIMEOUT_MS = 30000;      // 30秒测试超时
    static constexpr int PERFORMANCE_TEST_DURATION_MS = 5000; // 5秒性能测试
    static constexpr int TEST_FILE_COUNT = 100;       // 100个测试文件
};

#endif // RESPONSIVETEST_H